The principle of double effect

The principle of double effect justifies actions that cause a foreseen bad side effect (e.g., pain, death) while aiming for a good goal, provided the harm is unintended, proportionate, and not the means to the good end. Examples include administering high-dose pain medication that hastens death, performing life-saving surgeries during pregnancy, and tactical military strikes.  (Source: Reddit +4)

Key examples of the principle of double effect include:

Palliative Care/Pain Relief: A doctor administers a high dose of morphine to a terminal patient to manage severe pain, knowing this may accelerate the patient's death. The action is justified because the intention is to alleviate pain, not cause death.

Surgery During Pregnancy: A doctor removes a cancerous uterus to save a pregnant woman's life, which results in the unintended, foreseen death of the fetus. The intent is to save the mother, not kill the fetus.

Tactical Bombing in War: A military force targets an enemy munitions depot, knowing that civilian casualties may occur nearby. The action is permissible because the goal is destroying the target, not killing civilians.

Self-Defense: A person uses lethal force to defend themselves from a mortal threat, intending to stop the attacker rather than kill them. The attacker's death is a foreseen but unintended consequence.
Trolley Problem: A bystander flips a switch to divert a runaway trolley away from five people, causing it to kill one person on a side track. The intention is to save the five, not kill the one. 
(Source: Stanford Encyclopedia of Philosophy  +7)

Conditions for the Principle to Apply
According to Wikipedia and other sources, for an action to be considered permissible under this principle, it must meet several criteria: 
* The action itself must be good or morally neutral.
* The agent must intend only the good effect, not the evil one.
* The evil effect cannot be the means to the good effect.
* There must be a proportionally grave reason for permitting the evil effect.
(Source: Wikipedia)